﻿using Microsoft.AspNetCore.Http;
using RuYiAdmin.Net.Common.Utility;
using RuYiAdmin.Net.Entity.BusinessDTO.SystemManagement;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RuYiAdmin.Net.Entity.CoreEntity
{
    /// <summary>
    /// Session上下文
    /// </summary>
    public class SessionContext
    {
        /// <summary>
        /// 当前用户
        /// </summary>
        /// <param name="httpContextAccessor">HttpContext</param>
        /// <returns></returns>
        public static SysUserDTO GetCurrentUserInfo(IHttpContextAccessor httpContextAccessor)
        {
            var token = httpContextAccessor.HttpContext.Request.Headers["token"];
            var user = RedisUtil.Get<SysUserDTO>(token);
            return user;
        }
    }
}
